// 创建管理员用户  如果已经存在则返回

const { db } = require('./Schema/connect')
const encrypt = require('./utils/encrypt')

const UserScema = require('./Schema/user')
const User = db.model("users", UserScema)

User
  .find({username: "admin"})
  .then(data => {
    if(data.length === 0) {
      new User({
        username: "admin",
        password: encrypt("admin"),
        role: 666,
        commentNum: 0,
        articleNum: 0
      })
      .save()
      .then()
      .catch(err => {
        console.log(err);
        
      })

    } else {
      console.log(`管理员用户名为->admin 密码为->admin`)
    }
  })
  